package com.atguigu.spzx.manager.service.impl;

import com.atguigu.spzx.manager.mapper.SysRoleMenuMapper;
import com.atguigu.spzx.manager.service.SysRoleMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * title:
 * author: zgl
 * date: 2024/1/2
 * description：
 */
@Service
public class SysRoleMenuServiceImpl implements SysRoleMenuService {
    @Autowired
    private SysRoleMenuMapper sysRoleMenuMapper;

    @Override
    public List<Long> getMenusByRoleId(Long roleId) {
        return sysRoleMenuMapper.getMenusByRoleId(roleId);
    }

    @Override
    public void assignMenus(Long roleId, List<Long> menuIds) {
        //删除已经存在的
        sysRoleMenuMapper.deleteByRoleId(roleId);
        //重新插入
        sysRoleMenuMapper.assignMenus(roleId,menuIds);
    }
}
